package com.longcai.service.fuyoupay.impl;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;

import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.longcai.entity.order.ClyjGoodsOrderDetails;
import com.longcai.entity.payment.fuyou.request.ClyjFuyouSubamountRule;
import com.longcai.fenzhuang.fuyou.BaseResponse;
import com.longcai.fenzhuang.fuyou.FuyouCommonPortMethod;
import com.longcai.mapper.fuyoupay.ClyjFuyouSubamountRuleMapper;
import com.longcai.service.fuyoupay.ClyjFuyouSubamountRuleService;
import com.longcai.vo.ClyjGoodsOrderDetailsVo;

/**
 * <p>
 * 富有支付分账规则录入表 服务实现类
 * </p>
 *
 * @author ZJ
 * @since 2019-03-31
 */
@Service
public class ClyjFuyouSubamountRuleServiceImpl extends ServiceImpl<ClyjFuyouSubamountRuleMapper, ClyjFuyouSubamountRule> implements ClyjFuyouSubamountRuleService {


	@Override
	public ClyjGoodsOrderDetailsVo ruleImport(ClyjGoodsOrderDetailsVo clyjGoodsOrderDetailsVo) {
		ClyjFuyouSubamountRule cfsr=new ClyjFuyouSubamountRule();
		List<ClyjGoodsOrderDetails> list= clyjGoodsOrderDetailsVo.getClyjGoodsOrderDetails();
		ArrayList<ClyjFuyouSubamountRule> cfsrList=new ArrayList<>();
		FuyouCommonPortMethod fcpm = new FuyouCommonPortMethod();
		BaseResponse r = fcpm.subamountRuleImport(clyjGoodsOrderDetailsVo);
		if(r.getRespCode().equals("0000")){
			clyjGoodsOrderDetailsVo.setSplitSsn(r.getSplitSsn());
			return clyjGoodsOrderDetailsVo;
		}
	/*if(r.getRespCode().equals("0000")){
			for (ClyjGoodsOrderDetails clyjGoodsOrderDetails : list) {
				cfsr.setId(UUID.randomUUID().toString().replace("-",""));
				cfsr.setMchntName("");
				cfsr.setSplitStartTime("2019-05-22");
				cfsr.setSplitCause("想分账");
				cfsr.setSplitInfo("xxx");
				cfsr.setSubType("0");
				cfsr.setAutoSplit("0");
				//cfsr.setParticipant(params.getString("participant"));//暂时，合同参与方
				cfsr.setIsRange("0");
				cfsr.setSplitAmt(clyjGoodsOrderDetails.getPayAmount().toString());//固定值
				//cfsr.setSplitRangeAmt("");
				cfsr.setSplitAccount(clyjGoodsOrderDetails.getMchId());//分账入账户
				cfsr.setPriorityLev("99");
				cfsr.setContractSsn(params.getString("contractSsn"));//暂时
				cfsr.setContractName(params.getString("contractName"));//暂时
				cfsr.setStartDate(params.getTimestamp("startDate"));//暂时
				cfsr.setEndDate(params.getTimestamp("endDate"));//暂时
				cfsr.setBusinessContract(params.getString("businessContract"));//暂时
				cfsr.setSubaccountContract(params.getString("subaccountContract"));//暂时
				cfsr.setCreateTime(new Date());//暂时、
	            cfsr.setSplitSsn(r.getSplitSsn());
	            cfsrList.add(cfsr);
			}
			
			return cfsrList;
*/		return null;
	}

}
